<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use App\Models\Users;
class UserLevels extends Authenticatable{
   
    protected $table = 'user_level';

    
    protected $fillable = [
        'id','name','limit_number','created_at','updated_at','icon'
    ];

    /**
     * 获取列表
     */
    protected function getList($fields = ['*']){
        $lists = $this->select($fields)->orderBy('limit_number', 'asc')->get();
        foreach($lists as $key=>$val){
        	
        	$lists[$key]['level_nums'] =count(Users::where('grade',$val['id'])->where('status','<>',-1)->select('*')->get());
        }
        return $lists;
    }
 
}
